<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>2018/12/3</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <!--好的代码像粥一样,是得用时间和精力熬的。-->
</head>
<body>
<input type="text" placeholder="username"><br>
<input type="text" placeholder="password"><br>
<input type="text" placeholder="phoneNumber"><br>
<button id="btn">提交</button>
</body>
<script>
    window.onload = function () {
        var btn = document.getElementById('btn');
        var input = document.getElementsByTagName('input');
        btn.onclick = function () {
            $.ajax({
                url: 'http://localhost:8080/reg',
                method: 'get',
                data: {
                    username: input[0].value,
                    password: input[1].value,
                    phoneNumber: input[2].value
                }
            })
                .then(function (data) {
                    console.log(data);
                })
                .catch(function (error) {
                    console.log(error);
                })
        }
    }
</script>
</html>
